<?php get_header(); ?>
    <div id="middle" class="fixed">
        <div class="main">
        	<div class="breadcrumbnav">当前位置：<?php if (function_exists('don_breadcrumbs')) don_breadcrumbs(); ?></div>
        	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
            <div class="single">
            	<h1><?php the_title(); ?></h1>
                <p class="date"><?php the_category('，') ?> - 发文时间：<?php the_time('Y年m月d日'); ?> - <a class="ds-thread-count" data-thread-key="<?php the_ID(); ?>" href="#aritcle-comment" title="<?php the_title(); ?>"></a></p>
                <?php include('spider.php'); ?>
                <div class="content"><?php the_content(); ?></div>
                <p class="bottom">
                	<a href="#" title=""><?php the_permalink() ?></a> - <span><?php the_time('Y-m-d'); ?></span> - <?php the_tags('',' - ',''); ?>
                </p>
                <?php include('spider.php'); ?>
                <div class="tuijian">
                	<table>
                      <tr>
                        <td class="title"><?php if (get_previous_post()) { previous_post_link('%link');} else {echo "没有了，已经是最后文章";} ?></td>
                        <td class="cate">Prev</td>
                        <td align="center" valign="top">上一篇</td>
                      </tr>
                      <tr>
                        <td class="title"><?php if (get_next_post()) { next_post_link('%link');} else {echo "没有了，已经是最新文章";} ?></td>
                        <td class="cate">Next</td>
                        <td align="center" valign="top">下一篇</td>
                      </tr>
                      <?php
					  $post_num = 8; 
					  $exclude_id = $post->ID; 
					  $posttags = get_the_tags(); $i = 0;
					  if ( $posttags ) { $tags = ''; foreach ( $posttags as $tag ) $tags .= $tag->name . ',';
					  $args = array(
						  'post_status' => 'publish',
						  'tag_slug__in' => explode(',', $tags), 
						  'post__not_in' => explode(',', $exclude_id), 
						  'caller_get_posts' => 1, 
						  'orderby' => 'comment_date', 
						  'posts_per_page' => $post_num
				  );
					  query_posts($args); 
					  while( have_posts() ) { the_post(); ?>
                      <tr>
                        <td class="title"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title_attribute(); ?></a></td>
                        <td class="cate"><?php the_category('，') ?></td>
                        <td class="date"><?php the_time('Y-m-d'); ?></td>
                      </tr>
					  <?php
						  $exclude_id .= ',' . $post->ID; $i ++;
					   } wp_reset_query();
					  }
					  if ( $i < $post_num ) { 
					  $cats = ''; foreach ( get_the_category() as $cat ) $cats .= $cat->cat_ID . ',';
					  $args = array(
						  'category__in' => explode(',', $cats), 
						  'post__not_in' => explode(',', $exclude_id),
						  'caller_get_posts' => 1,
						  'orderby' => 'comment_date',
						  'posts_per_page' => $post_num - $i
				  );
					   query_posts($args);
					   while( have_posts() ) { the_post(); ?>
					  <tr>
                        <td class="title"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title_attribute(); ?></a></td>
                        <td class="cate"><?php the_category('，') ?></td>
                        <td class="date"><?php the_time('Y-m-d'); ?></td>
                      </tr>
					  <?php
						  $i ++;
					   } wp_reset_query();
					  }
					  if ( $i  == 0 )  
					  echo '<tr><td class="title" colspan="3">暂没推荐文章.</tr>';
					  ?>
                    </table>
                </div>
                <div class="bdsharebuttonbox"><a href="#" class="bds_more" data-cmd="more"></a><a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a><a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a><a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a><a href="#" class="bds_tieba" data-cmd="tieba" title="分享到百度贴吧"></a></div>
                <?php include('spider.php'); ?>
            </div>
            <div id="aritcle-comment">
                <div class="ds-thread" data-thread-key="<?php the_ID(); ?>"></div>
            </div>
            <?php endwhile; endif; ?>
        </div>
        <?php get_sidebar(); ?>
    </div>
    <?php get_footer(); ?>